// MonsterClass.h
#include <cstring>
#include <iostream>
#include <cstring>  // 包含strcpy_s函数
#include <random>
#include <vector>       
#include <math.h>
using namespace std;
#pragma once
// 前向声明
class Skill;
class Monster;
class Battle;
class Player;
class Item;

/*世界会用到的结构体*/
struct position
{
    int x;
    int y;
};

/*元素属性*/
enum ElementType {
    Normal,
    Fire,
    Water,
    Grass,
};
/*系统运行状态*/
enum RunningType {
    OK,
    ERROR_
};
/*怪物状态*/
struct MonsterCondiction {
    unsigned poison : 1;
    unsigned burn : 1;
    unsigned freeze : 1;
    unsigned paralysis : 1;
    unsigned sleep : 1;
};

#pragma once
class Skill {
public:
    int skill_id;
    string skill_name;
    int skill_damage;
    int skill_cold;
    int skill_cost_MP;
    ElementType type;
    void (*effect)(Monster* source, Monster* target);

    // 构造函数声明
    void Creat(string skill_name, int skill_damage, int skill_cold,
        int skill_cost_MP, ElementType type,
        void (*effect)(Monster* source, Monster* target));

    // 技能发动函数声明
    void Use(Monster* source_monster, Monster* target_monster);
};

// 怪物类声明
/*一层技能封装，绑定技能和怪物*/
struct MonsterNowSkill {
    int cold_time;
    int MP_now;
    int MP_max;
    Skill* skill;
};
// 怪物本体类的声明
class Monster {
public:
    /*基础的属性*/
    string name;
    ElementType type;
    /*局外属性*/
    int xp;
    int level;
    int normal_HP;
    int normal_Attack;
    int normal_Defense;
    int normal_Speed;
    //四个技能的复合结构体
    MonsterNowSkill have_skill[4];
    /*局内属性*/
    Monster* enemy;
    int HP;
    int Attack;
    int Defense;
    int Speed;
    void (*myeffect[10])(Monster* source, Monster* target);//效果指针列表，得意之作
    MonsterCondiction Condiction = { 0 };//异常状态初始化为0
    bool isAlive;
    /*函数们在下面*/
    /*局外函数部分*/
    /*升级，技能学习函数*/
    void LevelUp();
    void debugSee();//调试用函数，打印怪物信息
    /*怪物生成构造函数*/
    void Creat(string name, ElementType type, int normal_HP = 20, int normal_Attack = 5, int normal_Defense = 0, int normal_Speed = 0, int xp = 0, int level = 1);
    /*满状态复活*/
    void Revive();
    /*局内函数部分*/
    void ShowInfo();
    /*受击函数*/
    void Hurt(int damage);
    /*延时性状态函数效果列表函数*/
    void EffectList();
    /*发动技能函数*/
    void SkillUse(int skill_id);
    virtual void evolution() = 0;
};
class Squirtle : public Monster {
    Squirtle(int level = 1);
    void evolution();
};
class Charmander : public Monster {
public:
    Charmander(int level = 1);
    void evolution();
};
class Bulbasaur : public Monster {
public:
    Bulbasaur(int level = 1);
    void evolution();
};
class Item {
public:
    /*固定属性*/
    string name;
    int cost;
    Skill* effect;
    /*可变属性*/
    int number;
    /*构造函数*/
    void Creat(string name, int cost, Skill* effect, int number = 1);
    /*使用道具*/
    void Use(Monster* monster);
};

class Player {
public:
    /*玩家属性*/
    string name;
    Monster* use_monster[4];
    bool have_item[2];
    int monsternum;
    int itemnum;
    position p;
    /*玩家初始化*/
    void PlayerInit(string name);
    void getpokmon(Monster* mymonster);
    void getitem();
};
class Battle {
public:
    /*指向怪物的指针*/
    Monster* your_monster;
    Monster* enemy_monster;
    Player* player1, player2;
    bool win;//胜利判定
    /*战斗初始化*/
    void Init(Monster* source, Monster* target);
    void Init(Player* player, Monster* enemy_monster);
    /*战斗开始*/
    void StartBattle();
    /*玩家回合*/
    void PlayerTurn();
    /*计算机回合*/
    void ComputerTurn();
    /*怪物行动轮*/
    void SelectAction();
    /*使用技能*/
    void SkillUse();
    /*使用道具*/
    void ItemUse();
    /*切换宝可梦*/
    void ChangeMonster();
    /*逃跑*/
    void RunAway();
};
